"""
@Author: marco
@Date: 2021-6-18 16:51:50
@description: https://www.cnblogs.com/luxiaojun/p/6567132.html
@LastEditors: marco
@LastEditTime: 2021-6-18 16:51:50
"""
import time

from app import sched
from app.data.car_flow import sync_data
from app.alg.gs_prection_ariam import arammodel

# 循环执行 (某一定时时刻执行)
# 每天凌晨30分执行
@sched.scheduled_job('cron', day_of_week='*', hour='1', minute='30', second='00')
# @sched.scheduled_job('interval', seconds=5)
def predict_cron_job():
    print("<cron_job> 同步数据 [" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '] 开始...')
    # 执行同步数据算法
    sync_data()
    print("<cron_job> 同步数据 [" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '] 结束...')

    # 执行预测算法
    print("<cron_job> 预测 [" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '] 开始...')
    arammodel.main()
    print("<cron_job> 预测 [" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '] 结束...')
